<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
    <script src="driver-2.0.js"></script>
    <script type="text/javascript">
        window.addEventListener("load", function(){
            driver.open({
                name: "god",
                tables: ["angale", "boy", "yesu"],
                success: function () {
                    for(var i=0; i<10000; i++) {
                        this.insert("boy", {"id": i+2, "name": String.fromCharCode(i), "age": i+5});
                    }
                    this.insert("boy", {"id": 1, "name": "b", "age": 10});
                    this.insert("yesu", {"id": 1, "name": "c", "age": 10});
                }
            });
        }, false);

        function insert(){

        }
        function select(){

        }
        function deleteRow(){
            driver.deleteRow("angale", "1");
        }
        function update(){

        }

       /* function Promise() {
            var self = this
            var _state = 0
            self.resolveVal = null
            self.rejectVal = null
            Object.defineProperty(this, "state", {
                set: function (state) {
                    _state = state
                    execute.call(this)
                },
                get: function (state) {
                    return _state
                }
            })
            function execute() {
                var state = self.state
                try {
                    switch (state) {
                        case 1:
                            self.resolveFn && self.resolveFn(self.resolveVal)
                            break;
                        case 2:
                            self.rejectFn && self.rejectFn(self.rejectVal)
                            break;
                        default:
                            break;
                    }
                } catch (e) {
                    self.errorFn && self.errorFn(e)
                }
            }
            self.resolve = function (val) {
                self.resolveVal = val
                self.state = 1
            }
            self.reject = function (val) {
                this.rejectVal = val
                this.state = 2
            }
            self.then = function(resolveFn, rejectFn) {
                this.resolveFn = resolveFn
                this.rejectFn = rejectFn
                execute.call(this)
                return this
            }
            self.catch = function (errorFn) {
                this.errorFn = errorFn
            }
        }

        function test(flag){
            var promise = new Promise()
            if (flag) {
                promise.resolve("aaaa")
            } else {
                promise.reject("bbb")
            }
            return promise;
        }

        test(1).then(function (success) {
            console.log(success, "then success")
        }, function (fail) {
            console.log(fail, "then fail")
        }).catch(function (error) {

        })

        function ajax(){
            var promise = new Promise()
            $.get("http://139.196.11.33:8680/api/index.html", function (rs) {
                promise.resolve(rs)
            })
            return promise
        }

        ajax().then(function (rs) {
            console.log(rs)
        })*/

    </script>
</head>
<body>
    <input type="button" value="insert" onclick="insert();"/>
    <input type="button" value="select" onclick="select();"/>
    <input type="button" value="deleteRow" onclick="deleteRow();"/>
    <input type="button" value="update" onclick="update();"/>
</body>
</html>